<template>
    <el-select v-model="dtoValue" v-bind="schema.option" class="select">
        <el-option v-for="item in schema.option?.enumList" :key="item.value" :label="item.label"
            :value="item.value"></el-option>
    </el-select>
</template>


<script setup>
import { ref, onMounted } from 'vue'

const props = defineProps({
    schemaKey: String,
    schema: Object
})
const emits = defineEmits(['loaded'])

const dtoValue = ref()

onMounted(() => {
    reset()
    emits('loaded')
})

const getValue = () => {
    return dtoValue.value ? {
        [props.schemaKey]: dtoValue.value
    } : {}
}

const reset = () => {
    dtoValue.value = props.schema?.option?.default
}

defineExpose({
    getValue,
    reset
})
</script>
